package com.example.knowledgeget1.KnowtController;

import com.example.knowledgeget1.KnowtCommon.Entity.Teach;
import com.example.knowledgeget1.KnowtCommon.Service.TeachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/teaches")
public class TeachController {
    @Autowired
    private TeachService teachService;

    @PostMapping("/")
    public Teach createTeach(@RequestBody Teach teach) {
        return teachService.createTeach(teach);
    }

    @GetMapping("/")
    public List<Teach> getAllTeaches() {
        return teachService.getAllTeaches();
    }

    @GetMapping("/{id}")
    public Teach getTeachById(@PathVariable Long id) {
        return teachService.getTeachById(id);
    }

    @PutMapping("/{id}")
    public Teach updateTeach(@PathVariable Long id, @RequestBody Teach teach) {
        return teachService.updateTeach(id, teach);
    }

    @DeleteMapping("/{id}")
    public void deleteTeach(@PathVariable Long id) {
        teachService.deleteTeach(id);
    }
}